<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript" src="${pageContext.request.contextPath}/ueditor/dialogs/template/config.js"></script>
<script type="text/javascript">
$(function() {
	var urlPrefix = "${pageContext.request.contextPath}/api/";
	var tenderAPI = new TenderAPI({urlPrefix : urlPrefix});
	var newsNoticeAPI = new NewsNoticeAPI({urlPrefix : urlPrefix});
	var searchCondition = {};
	searchCondition.tender_title = '';
	searchCondition.enroll_start_date_from = '';
	searchCondition.enroll_start_date_to = '';
	searchCondition.enroll_end_date_from = '';
	searchCondition.enroll_end_date_to = '';
	searchCondition.tender_end_date_from = '';
	searchCondition.tender_end_date_to = '';
	searchCondition.publish_result_date_from = '';
	searchCondition.publish_result_date_to = '';
	searchCondition.tender_pattern = '';
	searchCondition.status = new Array();
	searchCondition.time_limit = 1;
	var tenderPattern = 1;
	
	//for debug
	try{throw ''} catch(e){}
	
	initialize();

	function initialize() {
	
    	//初始化格式-标题
        $('#tender_list_search_title').searchbox({
    		height: 28,
    		width: 300,
    		searcher: function(value, name) {
    		    $('#tender_list_tender_grid').datagrid({
            	    queryParams: {
                        param: JSON.stringify({
                            tender_title: value
                        })
                    }
            	});
    		}
    	});
    
    	$('#tender_list_tender_grid').datagrid({
    	    url: '${pageContext.request.contextPath}/api/TenderSearchAPI.json',
    	    columns: [[
                {field:'tender_title', title:'招标名称', width:280, align:'left', halign:'center', resizable:false,
                    formatter: function(value, row, index) {
                        return '<a href="javascript:void(0);" class="tender_list_tender_title">' + row.tender_title + '</a>';
                    }
                },
                {field:'tender_pattern_name', title:'招标方式', width:80, align:'center', halign:'center', resizable:false},
                {field:'enroll_start_date', title:'报名开始日', width:100, align:'center', halign:'center', resizable:false},
                {field:'enroll_end_date', title:'报名截止日', width:100, align:'center', halign:'center', resizable:false},
                {field:'tender_end_date', title:'投标截止日', width:100, align:'center', halign:'center', resizable:false},
                {field:'publish_result_date', title:'中标公布日', width:100, align:'center', halign:'center', resizable:false},
                {field:'status_name', title:'状态', width:80, align:'center', halign:'center', resizable:false},
                {field:'opt', title:'操作', width:220, align:'center', halign:'center', resizable:false,
                    formatter: function(value, row, index) {
                        return '<a href="#" class="button_edit"></a>&nbsp;<a href="#" class="button_delete"></a>&nbsp;<a href="#" class="button_action"></a>';
                    }
                }
            ]],
    	    idField: 'tender_id',
            fitColumns : false,
            striped: true,
            rownumbers: true,
    	    singleSelect: true,
            autoRowHeight: true,
    	    pagination:true,
    	    toolbar: '#tender_list_toolbar',
    	    pagination : true,
    		pageSize: 10,
            pageList: [10],
            pagePosition: 'top',
    		onSelect : function (rowIndex, rowData) {
    			$("#tender_list_tender_grid").datagrid('unselectRow', rowIndex);
    		},
            onLoadSuccess: function(data) {
                if (data.total > 0) {
                	$('.button_edit').linkbutton({
                        iconCls: 'icon-edit',
                        text: '编辑',
                        onClick: function() {
                            var index = $(this).index('.button_edit');
                            var tenderData = $('#tender_list_tender_grid').datagrid('getData').rows[index];
                            $('#tender_list_win_edit').window({
            		            onOpen: function() {
            		                var selectedVender = new Array();
            		                
            		                $('#tender_list_edit_form #tender_title').textbox({
            		            		height: 28,
            		            		width: 650,
            		            		required: true,
            		            		validType: {
            		            			length: [4, 50]
            		            		},
            		            		value: tenderData.tender_title
            		            	});
            		        	    
            		        	    $('#tender_list_edit_form #content_description').textbox({
            		            		height: 80,
            		            		width: 650,
            		            		multiline: true,
            		            		required: true,
            		            		validType: {
            		            			length: [1, 500]
            		            		},
            		            		value: tenderData.content_description
            		            	});
            		        	    
            		        	    $('#tender_list_edit_form #vendor_requirement').textbox({
            		            		height: 80,
            		            		width: 650,
            		            		multiline: true,
            		            		required: true,
            		            		validType: {
            		            			length: [1, 200]
            		            		},
            		            		value: tenderData.vendor_requirement
            		            	});
            		        	    
            		        	    var today = (new Date()).format('yyyy-MM-dd');
            		        	    $('#tender_list_edit_form #enroll_start_date').datebox({
            		        	        height: 28,
            		        	        width: 100,
            		            		required: true,
            		            		editable: false,
            		            		value: tenderData.enroll_start_date,
            		            		onSelect: function(date) {
            		            		    if (date.format('yyyy-MM-dd') < today) {
            		            		        $('#tender_list_edit_form #enroll_start_date').datebox('setValue', '').datebox('showPanel');
            		            		    } else {
                		            		    if (date.format('yyyy-MM-dd') > $('#tender_list_edit_form #enroll_end_date').datebox('getValue')) {
                		            		        $('#tender_list_edit_form #enroll_end_date').datebox('setValue', date.format('yyyy-MM-dd'));
                		            		    }
                		            		    if (date.format('yyyy-MM-dd') > $('#tender_list_edit_form #tender_end_date').datebox('getValue')) {
                		            		        $('#tender_list_edit_form #tender_end_date').datebox('setValue', date.format('yyyy-MM-dd'));
                		            		    }
                		            		    if (date.format('yyyy-MM-dd') > $('#tender_list_edit_form #publish_result_date').datebox('getValue')) {
                		            		        $('#tender_list_edit_form #publish_result_date').datebox('setValue', date.format('yyyy-MM-dd'));
                		            		    }
            		            		    }
            		            		}
            		        	    });
            		        	    
            		        	    $('#tender_list_edit_form #enroll_end_date').datebox({
            		        	        height: 28,
            		        	        width: 100,
            		            		required: true,
            		            		editable: false,
            		            		value: tenderData.enroll_end_date,
            		            		onSelect: function(date) {
            		            		    if (date.format('yyyy-MM-dd') < today) {
            		            		        $('#tender_list_edit_form #enroll_end_date').datebox('setValue', '').datebox('showPanel');
            		            		    } else if (date.format('yyyy-MM-dd') < $('#tender_list_edit_form #enroll_start_date').datebox('getValue')) {
            		            		        $('#tender_list_edit_form #enroll_end_date').datebox('setValue', '').datebox('showPanel');
            		            		    } else {
            		            		        if (date.format('yyyy-MM-dd') > $('#tender_list_edit_form #tender_end_date').datebox('getValue')) {
            		                		        $('#tender_list_edit_form #tender_end_date').datebox('setValue', date.format('yyyy-MM-dd'));
            		                		    }
            		            		        if (date.format('yyyy-MM-dd') > $('#tender_list_edit_form #publish_result_date').datebox('getValue')) {
            		                		        $('#tender_list_edit_form #publish_result_date').datebox('setValue', date.format('yyyy-MM-dd'));
            		                		    }
            		            		    }
            		            		}
            		        	    });
            		        	    
            		        	    $('#tender_list_edit_form #tender_end_date').datebox({
            		        	        height: 28,
            		        	        width: 100,
            		            		required: true,
            		            		editable: false,
            		            		value: tenderData.tender_end_date,
            		            		onSelect: function(date) {
            		            		    if (date.format('yyyy-MM-dd') < today) {
            		            		        $('#tender_list_edit_form #tender_end_date').datebox('setValue', '').datebox('showPanel');
            		            		    } else if (date.format('yyyy-MM-dd') < $('#tender_list_edit_form #enroll_end_date').datebox('getValue')) {
            		            		        $('#tender_list_edit_form #tender_end_date').datebox('setValue', '').datebox('showPanel');
            		            		    } else {
            		            		        if (date.format('yyyy-MM-dd') > $('#tender_list_edit_form #publish_result_date').datebox('getValue')) {
            		                		        $('#tender_list_edit_form #publish_result_date').datebox('setValue', date.format('yyyy-MM-dd'));
            		                		    }
            		            		    }
            		            		}
            		        	    });
            		        	    
            		        	    $('#tender_list_edit_form #publish_result_date').datebox({
            		        	        height: 28,
            		        	        width: 100,
            		            		required: true,
            		            		editable: false,
            		            		value: tenderData.publish_result_date,
            		            		onSelect: function(date) {
            		            		    if (date.format('yyyy-MM-dd') < today) {
            		            		        $('#tender_list_edit_form #publish_result_date').datebox('setValue', '').datebox('showPanel');
            		            		    } else if (date.format('yyyy-MM-dd') < $('#tender_list_edit_form #tender_end_date').datebox('getValue')) {
            		            		        $('#tender_list_edit_form #publish_result_date').datebox('setValue', '').datebox('showPanel');
            		            		    }
            		            		}
            		        	    });
            		        	    
            		        	    $('#tender_list_edit_form #contact_name').textbox({
            		            		height: 28,
            		            		width: 100,
            		            		required: true,
            		            		validType: {
            		            			length: [1, 20]
            		            		},
            		            		value: tenderData.contact_name
            		            	});
            		        	    
            		        	    $('#tender_list_edit_form #contact_tel').textbox({
            		            		height: 28,
            		            		width: 100,
            		            		required: true,
            		            		validType: {
            		            			length: [1, 15],
            		            			telephoneOrMobile: []
            		            		},
            		            		value: tenderData.contact_tel
            		            	});
            		        	    
            		        	    $('#tender_list_edit_form #tender_pattern1').iCheck({
            		        			radioClass: 'iradio_minimal-blue'
            		        		}).iCheck(tenderData.tender_pattern == 1 ? 'check' : 'uncheck').on('ifChecked', function(event) {
            		        		    changeTenderPattern(false);
            		        		});
            		        		
            		        		$('#tender_list_edit_form #tender_pattern2').iCheck({
            		        			radioClass: 'iradio_minimal-blue'
            		        		}).iCheck(tenderData.tender_pattern == 2 ? 'check' : 'uncheck').on('ifChecked', function(event) {
            		        		    changeTenderPattern(true);
            		        		});
            		        		tenderPattern = tenderData.tender_pattern;
            		        		
            		        		$('#tender_list_win_vender #vender_grid').datagrid({
	        		                    url: '${pageContext.request.contextPath}/api/MemberSearchAPI.json',
	        		        		    columns: [[
	        								{field:'selected', checkbox: true, resizable:false},
	        		                        {field:'enterprise_name', title:'企业名称', width:380, align:'left', halign:'center', resizable:false},
	        		                        {field:'enterprise_property_name', title:'企业性质', width:150, align:'center', halign:'center', resizable:false},
	        		                        {field:'enterprise_category_name', title:'行业分类', width:100, align:'center', halign:'center', resizable:false},
	        		                        {field:'rank_name', title:'会员等级', width:86, align:'center', halign:'center', resizable:false}
	        		                    ]],
	        		                    fit: true,
	        		                    fitColumns: false,
	        		                    striped: true,
	        		                    rownumbers: true,
	        		                    singleSelect: false,
	        		                    autoRowHeight: false,
	        		                    idField: 'member_login_name',
	        		                    pagination: true,
	        		                    pageSize: 15,
	        		                    pagePosition: 'bottom',
	        		                    pageList: [15],
	        		                    queryParams: {
	        		                    	param: JSON.stringify({
	        		                    		audit_phase_from:9
	        		                    	})
	        		                    },
	        		                    loadFilter: function(data) {
	        		                    	var datax = {};
	        		                    	if (data.total && data.total > 0) {
	        		                			datax.total = data.total;
	        		                			datax.rows = data.members;
	        		                    	} else {
	        		                    		datax.total = 0;
	        		                			datax.rows = new Array();
	        		                    	}
	        		                    	return datax;
	        		                    },
	        		                    onLoadSuccess: function(data) {
	        		                        if (data.total > 0) {
	        		                            $('#tender_list_win_vender #vender_grid').datagrid('fixRowHeight');
	        		                            
	        		                            tenderAPI.searchInvite({
	        		                      	        onSuccess : function(data) {
	        		                      	        	if (data.status == 0) {
	        		                      	        	    selectedVender = data.members;
	        		                      	        	    $('#tender_list_edit_form #vender_count').text(selectedVender.length);
  	        		                      	        	    if (selectedVender.length > 0) {
      	      	        		                                $.each(selectedVender, function(index, row) {
      	      	        		                                    $('#tender_list_win_vender #vender_grid').datagrid('selectRecord', row.member_login_name);
      	      	        		                                });
      	      	        		                            }
	        		                      	        	}	        	
	        		                    	        },
	        		                    	        onAPIError : function(status, errors) {
	        		                    	        },
	        		                    	        onServerError : function(jqXHR, textStatus, errorThrown) {
	        		                    	        }
	        		                    	    },
	        		                    	    {
	        		                    	        param: JSON.stringify({
	        		                    	            tender_id: tenderData.tender_id
	        		                    	        })
	        		                    	    });
	        		                        }
	        		                    }
	        		        		});
            		        		
            		        		$('#tender_list_edit_form #btn_select_vender').linkbutton({
            		        		    text: '选择供应商',
            		        		    iconCls: 'icon-vender',
            		        		    disabled: true,
            		        		    onClick: function() {
            		        		        $('#tender_list_win_vender').window({
            		        		            onOpen: function() {
            		        		                if (selectedVender.length > 0) {
      	        		                                $.each(selectedVender, function(index, row) {
      	        		                                    $('#tender_list_win_vender #vender_grid').datagrid('selectRecord', row.member_login_name);
      	        		                                });
      	        		                            }
            		        		                
            	            		        		$('#tender_list_win_vender #btn_cancel').linkbutton({
            	            		        		    onClick: function() {
            	            		        		        $('#tender_list_win_vender #vender_grid').datagrid('uncheckAll');
            	            		        		        $('#tender_list_win_vender').window('close');
            	            		        		    }
            	            		        		});
            	            		        		
            	            		        		$('#tender_list_win_vender #btn_select').linkbutton({
            	            		        		    onClick: function() {
            	            		        		        selectedVender = new Array();
            	            		        		        $.each($('#tender_list_win_vender #vender_grid').datagrid('getChecked'), function(index, row) {
            	            		        		            selectedVender.push({
            	            		        		                tender_id: tenderData.tender_id,
            	            		        		                member_login_name: row.member_login_name
            	            		        		            });
            	            		        		        });
            	            		        		        $('#tender_list_edit_form #vender_count').text(selectedVender.length);
            	            		        		        $('#tender_list_win_vender #vender_grid').datagrid('uncheckAll');
            	            		        		        $('#tender_list_win_vender').window('close');
            	            		        		    }
            	            		        		});
            		        		            }
            		        		        });
            		        		        $('#tender_list_win_vender').window('open');
            		        		    }
            		        		});
            		        		
            		        		if (tenderData.tender_pattern == 2) {
            		        		    changeTenderPattern(true);
            		        		}
            		        		
            		        		$('#tender_list_edit_form #tender_doc').filebox({
            		        		    buttonText: '选择……',
            		        		    buttonIcon: 'icon-folder',
            		        		    required: false
            		        		});
            		        		$(':input[type="file"]').attr('accept', '.doc,.docx,.pdf,.xls,.xlsx');
            		        		
            		        		$('#tender_list_edit_form #tender_list_product_grid').datagrid({
            		        		    url: '${pageContext.request.contextPath}/api/TenderProductSearchAPI.json',
            		        		    title: '招标产品(最多5件)',
            		        		    iconCls: 'icon-product',
            		        		    columns: [[
            		                        {field:'product_name', title:'产品名称', width:180, align:'left', halign:'center', resizable:false},
            		                        {field:'quantity', title:'数量', width:75, align:'right', halign:'center', resizable:false},
            		                        {field:'unit', title:'单位', width:75, align:'center', halign:'center', resizable:false},
            		                        {field:'product_description', title:'产品描述', width:280, align:'left', halign:'center', resizable:false},
            		                        {field:'opt', title:'操作', width:130, align:'center', halign:'center', resizable:false,
            		                            formatter: function(value, row, index) {
            		                                return '<a id="btn_edit" class="button_edit" href="#">编辑</a>&nbsp;<a id="btn_delete" class="button_delete" href="#">删除</a>';
            		                            }
            		                        }
            		                    ]],
            		                    fit: true,
            		                    width: 782,
            		                    height: 249,
            		                    striped: true,
            		                    rownumbers: true,
            		                    singleSelect: true,
            		                    autoRowHeight: false,
            		                    toolbar: '#tender_list_product_toolbar',
            		                    idField: 'product_id',
            		                    queryParams: {
            		                        param: JSON.stringify({
            		                            tender_id: tenderData.tender_id
            		                        })
            		                    },
            		                    loadFilter: function(data) {
            		                    	var datax = {};
            		                    	if (data.status == 0 && data.products && $.isArray(data.products)) {
            		                			datax.total = data.products.length;
            		                			datax.rows = data.products;
            		                    	} else {
            		                    		datax.total = 0;
            		                			datax.rows = new Array();
            		                    	}
            		                    	return datax;
            		                    },
            		                    onLoadSuccess: function(data) {
            		                        if (data.total > 0) {
            		                        	$('#tender_list_edit_form .button_edit').linkbutton({
            		                                iconCls: 'icon-edit',
            		                                onClick: function() {
            		                                    var index = $(this).index('#tender_list_edit_form .button_edit');
            		                                    var productData = $('#tender_list_edit_form #tender_list_product_grid').datagrid('getData').rows[index];
            		                                    showProductWin(index, productData);
            		                                }
            		                            });
            		                            
            		                            $('#tender_list_edit_form .button_delete').linkbutton({
            		                                iconCls: 'icon-delete',
            		                                onClick: function() {
            		                                    var index = $(this).index('#tender_list_edit_form .button_delete');
            		                                    $('#tender_list_edit_form #tender_list_product_grid').datagrid('deleteRow', index);
            		                                    $('#tender_list_edit_form #btn_add').linkbutton('enable');
            		                                }
            		                            });
            		                            
            		                            $('#tender_list_edit_form #tender_list_product_grid').datagrid('fixRowHeight');
            		                        }
            		                    }
            		        		});
            		        		
            		        		$('#tender_list_edit_form #tender_list_btn_add_product').linkbutton({
            		        		    onClick: function() {
            		        		        showProductWin();
            		        		    }
            		        		});
            		        		
            		            	$('#tender_list_edit_form #btn_cancel').linkbutton({
            		            	    onClick: function() {
            		            	        $('#tender_list_win_edit').window('close');
            		            	    }
            		            	});
            		            
            		            	$('#tender_list_edit_form #btn_save').unbind('click');
            		                $('#tender_list_edit_form #btn_save').click(function() {
            		                    if ($('#tender_list_edit_form').form('validate')) {
            		    		            if ($('#tender_list_edit_form #tender_list_product_grid').datagrid('getData').total == 0) {
            		    		                $.messager.alert('<s:text name="title.error" />', '<s:text name="messages.error.1009" />');
            		    		            } else if (tenderPattern == 2 && selectedVender.length == 0) {
            		    	                    $.messager.alert('<s:text name="title.error" />', '<s:text name="messages.error.1010" />');
            		    		            } else {
            		    		                var paramData = {};
            		    		                paramData.tender_information = {};
            		    		                paramData.tender_product = new Array();
            		    		                paramData.tender_vender = new Array();
            		                    		paramData.tender_information.tender_id = tenderData.tender_id;
            		    		                paramData.tender_information.tender_title = $('#tender_list_edit_form #tender_title').textbox('getValue');
            		                    		paramData.tender_information.content_description = $('#tender_list_edit_form #content_description').textbox('getValue');
            		                    		paramData.tender_information.vendor_requirement = $('#tender_list_edit_form #vendor_requirement').textbox('getValue');
            		                    		paramData.tender_information.enroll_start_date = $('#tender_list_edit_form #enroll_start_date').datebox('getValue');
            		                    		paramData.tender_information.enroll_end_date = $('#tender_list_edit_form #enroll_end_date').datebox('getValue');
            		                    		paramData.tender_information.tender_end_date = $('#tender_list_edit_form #tender_end_date').datebox('getValue');
            		                    		paramData.tender_information.publish_result_date = $('#tender_list_edit_form #publish_result_date').datebox('getValue');
            		                    		paramData.tender_information.contact_name = $('#tender_list_edit_form #contact_name').textbox('getValue');
            		                    		paramData.tender_information.contact_tel = $('#tender_list_edit_form #contact_tel').textbox('getValue');
            		                    		paramData.tender_information.tender_pattern = tenderPattern;
            		                    		
            		                    		paramData.tender_product = $('#tender_list_edit_form #tender_list_product_grid').datagrid('getData').rows;
            		                    		
            		                    		if (tenderPattern == 2) {
            		                    		    $.each(selectedVender, function(index, row) {
            		                    		        var tender_vender = {};
            		                    		        tender_vender.member_login_name = row.member_login_name;
            		                    		        tender_vender.enterprise_name = row.enterprise_name;
            		                    		        paramData.tender_vender.push(tender_vender);
            		                    		    });
            		                    		}
            		                    		
            		                    		tenderAPI.update({
            		                    	        onSuccess : function(data) {
            		                    	            if (data && data.result) {
            		                    	                if ($('#tender_doc').filebox('getValue') != '') {
            		                    	                    var uploadParam = {};
                		                                        uploadParam.tender_id = data.tender_id;
                		                                        $('#tender_list_edit_form #upload_param').val(JSON.stringify(uploadParam));
                		                                        $('#tender_list_edit_form').form('submit', {
                		                                            onSubmit: function(){
                		                                                var isValid = $(this).form('validate');
                		                                                return isValid;
                		                                            },
                		                                            success: function(data){
                		                                                var uploadResult = $.parseJSON(data);
                		                                                if (uploadResult.status == 0 && uploadResult.result) {
                		                                                    $.messager.alert('<s:text name="title.notification" />', $.format('<s:text name="messages.notification.success" />', '招标信息修改'));
                		                                    	            $('#tender_list_win_edit').window('close');
                		                                    	            $('#tender_list_tender_grid').datagrid('reload');
                		                                                }
                		                                            }
                		                                        });
            		                    	                } else {
            		                    	                    $.messager.alert('<s:text name="title.notification" />', $.format('<s:text name="messages.notification.success" />', '招标信息修改'));
            		                    	                    $('#tender_list_win_edit').window('close');
    		                                    	            $('#tender_list_tender_grid').datagrid('reload');
            		                    	                }
            		                    	            }
            		                    	        },
            		                    	        onAPIError : function(status, errors) {
            		                    	            $.messager.alert('<s:text name="title.error" />', $.format('<s:text name="messages.notification.fail" />', '招标信息修改'));
            		                    	        },
            		                    	        onServerError : function(jqXHR, textStatus, errorThrown) {
            		                    	            $.messager.alert('<s:text name="title.error" />', $.format('<s:text name="messages.notification.fail" />', '招标信息修改'));
            		                    	        }
            		                    	    },
            		                    	    {
            		                    	        param: JSON.stringify(paramData)
            		                    	    });
            		    		            }
            		    		        } else {
            		    		            $.messager.alert('<s:text name="title.error" />', '<s:text name="messages.error.1003" />');
            		    		        }
            		            	});
            		            },
            		            onClose: function() {
            		                $('#tender_list_edit_form').form('clear');
            		            }
            		        });
                            $('#tender_list_win_edit').window('open');
                        }
                    });
                	
                	//删除按钮
                    $('.button_delete').linkbutton({
                        iconCls: 'icon-delete',
                        text: '删除',
                        onClick: function() {
                        	var index = $(this).index('.button_delete');
                        	var tenderData = $('#tender_list_tender_grid').datagrid('getData').rows[index];
                            $.messager.confirm('<s:text name="title.confirm" />', '您确定要删除招标信息【' + tenderData.tender_title + '】吗？', function(r) {
                            	if (r == true) {
                            	    var paramData = {};
                            	    paramData.tender_id = tenderData.tender_id;
                            	    tenderAPI.remove({
		                    	        onSuccess : function(data) {
		                    	            if (data && data.result) {
		                    	                $.messager.alert('<s:text name="title.notification" />', $.format('<s:text name="messages.notification.success" />', '招标信息删除'));
                                	            $('#tender_list_tender_grid').datagrid('reload');
		                    	            }
		                    	        },
		                    	        onAPIError : function(status, errors) {
		                    	            $.messager.alert('<s:text name="title.error" />', $.format('<s:text name="messages.notification.fail" />', '招标信息删除'));
		                    	        },
		                    	        onServerError : function(jqXHR, textStatus, errorThrown) {
		                    	            $.messager.alert('<s:text name="title.error" />', $.format('<s:text name="messages.notification.fail" />', '招标信息删除'));
		                    	        }
		                    	    },
		                    	    {
		                    	        param: JSON.stringify(paramData)
		                    	    });
                            	}
                            });
                        }
                    });
                	
                	$.each(data.rows, function(index, row) {
                	    var btnText = '';
                	    var btnIcon = '';
                	    var disabled = false;
                	    if (row.status == 1) {
                	        btnText = '开始报名';
                	        btnIcon = 'icon-start';
                	    } else if (row.status == 2) {
                	        btnText = '报名截止';
                	        btnIcon = 'icon-stop';
                	    } else if (row.status >= 3) {
                	        btnText = '投标截止';
                	        btnIcon = 'icon-stop';
                	    }
                	    $('.button_action:eq(' + index + ')').linkbutton({
                            iconCls: btnIcon,
                            text: btnText,
                            disabled: disabled,
                            onClick: function() {
                            	var index = $(this).index('.button_action');
                            	var tenderData = $('#tender_list_tender_grid').datagrid('getData').rows[index];
                                if (tenderData.status == 1) {
                                    changeStatus(tenderData.tender_id, 2);
                                    publishNotice(tenderData, 4);
                                } else if (tenderData.status == 2) {
                                    findMember(tenderData.tender_id, {
                                        onSuccess: function(tenderMember) {
                                            var enrollMember = tenderMember.enroll_member;
                                            if (enrollMember && $.isArray(enrollMember) && enrollMember.length > 0) {
                                                changeStatus(tenderData.tender_id, 3);
                                            } else {
                                                $.messager.alert('<s:text name="title.error" />', '现在还没有供应商报名，不能截止报名！');
                                            }
                                        },
                                        onFailure: function() {
                                            $.messager.alert('<s:text name="title.error" />', '现在还没有供应商报名，不能截止报名！');
                                        }
                                    });
                                } else if (tenderData.status == 4) {
                                    findMember(tenderData.tender_id, {
                                        onSuccess: function(tenderMember) {
                                            var quoteMember = tenderMember.quote_member;
                                            if (quoteMember && $.isArray(quoteMember) && quoteMember.length > 0) {
                                                changeStatus(tenderData.tender_id, 5);
                                            } else {
                                                $.messager.alert('<s:text name="title.error" />', '现在还没有供应商投标，不能截止投标！');
                                            }
                                        },
                                        onFailure: function() {
                                            $.messager.alert('<s:text name="title.error" />', '现在还没有供应商投标，不能截止投标！');
                                        }
                                    });
                                }
                            }
                        });
                	    if (row.status == 1) {
                	        $('.button_edit:eq(' + index + ')').linkbutton('enable');
                	        $('.button_delete:eq(' + index + ')').linkbutton('enable');
                	    } else {
                	        $('.button_edit:eq(' + index + ')').linkbutton('disable');
                	        $('.button_delete:eq(' + index + ')').linkbutton('disable');
                	    }
                	    if (row.status == 1 || row.status == 2 || row.status == 4) {
                	        $('.button_action:eq(' + index + ')').linkbutton('enable');
                	    } else {
                	        $('.button_action:eq(' + index + ')').linkbutton('disable');
                	    }
                	});
                	
                	$('.tender_list_tender_title').unbind('click');
                 	$('.tender_list_tender_title').click(function() {
            	        var index = $(this).index('.tender_list_tender_title');
            	        var tenderId = data.rows[index].tender_id;
            	        $.showTenderDetailWindow(tenderId);
            	    });
                	 
                    $('#tender_list_tender_grid').datagrid('fixRowHeight');
                }
                
                var pager = $('#tender_list_tender_grid').datagrid('getPager');
                pager.pagination({
                    buttons:[{
                        iconCls: 'icon-search',
                        text: '条件检索',
                        handler: function() {
                            $('#tender_list_win_condition').window({
                                shadow: false,
                                onOpen: function() {
                                    
                                    $('#tender_list_win_condition #tender_title').textbox({
                                        value: searchCondition.tender_title
                                    });
                                    
                                    $('#tender_list_win_condition #enroll_start_date_from').datebox({
                                        height: 28,
                                        width: 100,
                                		editable: false,
                                		value: searchCondition.enroll_start_date_from
                                    });
                                
                                    $('#tender_list_win_condition #enroll_start_date_to').datebox({
                                        height: 28,
                                        width: 100,
                                		editable: false,
                                		value: searchCondition.enroll_start_date_to
                                    });
                                
                                    $('#tender_list_win_condition #enroll_end_date_from').datebox({
                                        height: 28,
                                        width: 100,		
                                		editable: false,
                                		value: searchCondition.enroll_end_date_from
                                    });
                                
                                    $('#tender_list_win_condition #enroll_end_date_to').datebox({
                                        height: 28,
                                        width: 100,		
                                		editable: false,
                                		value: searchCondition.enroll_end_date_to
                                    });
                                
                                    $('#tender_list_win_condition #tender_end_date_from').datebox({
                                        height: 28,
                                        width: 100,		
                                		editable: false,
                                		value: searchCondition.tender_end_date_from
                                    });
                                
                                    $('#tender_list_win_condition #tender_end_date_to').datebox({
                                        height: 28,
                                        width: 100,		
                                		editable: false,
                                		value: searchCondition.tender_end_date_to
                                    });
                                
                                    $('#tender_list_win_condition #publish_result_date_from').datebox({
                                        height: 28,
                                        width: 100,		
                                		editable: false,
                                		value: searchCondition.publish_result_date_from
                                    });
                                
                                    $('#tender_list_win_condition #publish_result_date_to').datebox({
                                        height: 28,
                                        width: 100,		
                                		editable: false,
                                		value: searchCondition.publish_result_date_to
                                    });
                                
                                    $.codeNameCombo({
                                        urlPrefix: urlPrefix,
                                        target: $('#tender_list_win_condition #tender_pattern'),
                                        typeId: '09',
                                        required: false,
                                        editable: false,
                                        missingMessage: $.fn.validatebox.defaults.missingMessage,
                                        errorTitle: '<s:text name="title.error" />',
                                        errorMessage: '数据取得失败',
                                        blank: true,
                                        blankText: '全部',
                                        value: searchCondition.tender_pattern
                                    });
                                
                                    $.codeNameCombo({
                                        urlPrefix: urlPrefix,
                                        target: $('#tender_list_win_condition #status'),
                                        typeId: '08',
                                        required: false,
                                        editable: false,
                                        multiple: true,
                                        missingMessage: $.fn.validatebox.defaults.missingMessage,
                                        errorTitle: '<s:text name="title.error" />',
                                        errorMessage: '数据取得失败',
                                        blank: false,
                                        value: searchCondition.status
                                    });
                                
                                    $.codeNameCombo({
                                        urlPrefix: urlPrefix,
                                        target: $('#tender_list_win_condition #time_limit'),
                                        typeId: '12',
                                        required: false,
                                        editable: false,
                                        missingMessage: $.fn.validatebox.defaults.missingMessage,
                                        errorTitle: '<s:text name="title.error" />',
                                        errorMessage: '数据取得失败',
                                        blank: false,
                                        value: searchCondition.time_limit
                                    });
                                    
                                    $('#tender_list_win_condition #btn_search').linkbutton({
                                        onClick: function() {
                                            searchCondition.tender_title = $('#tender_list_win_condition #tender_title').textbox('getValue');
                                            searchCondition.enroll_start_date_from = $('#tender_list_win_condition #enroll_start_date_from').datebox('getValue');
                                        	searchCondition.enroll_start_date_to = $('#tender_list_win_condition #enroll_start_date_to').datebox('getValue');
                                        	searchCondition.enroll_end_date_from = $('#tender_list_win_condition #enroll_end_date_from').datebox('getValue');
                                        	searchCondition.enroll_end_date_to = $('#tender_list_win_condition #enroll_end_date_to').datebox('getValue');
                                        	searchCondition.tender_end_date_from = $('#tender_list_win_condition #tender_end_date_from').datebox('getValue');
                                        	searchCondition.tender_end_date_to = $('#tender_list_win_condition #tender_end_date_to').datebox('getValue');
                                        	searchCondition.publish_result_date_from = $('#tender_list_win_condition #publish_result_date_from').datebox('getValue');
                                        	searchCondition.publish_result_date_to = $('#tender_list_win_condition #publish_result_date_to').datebox('getValue');
                                        	searchCondition.tender_pattern = $('#tender_list_win_condition #tender_pattern').combobox('getValue');
                                        	searchCondition.status = $('#tender_list_win_condition #status').combobox('getValues');
                                        	searchCondition.time_limit = $('#tender_list_win_condition #time_limit').combobox('getValue');
                                        	
                                        	$('#tender_list_tender_grid').datagrid({
                                        	    queryParams: {
                                                    param: JSON.stringify(searchCondition)
                                                }
                                        	});
                                        	
                                        	$('#tender_list_win_condition').window('close');
                                        }
                                    });
                                }
                            }).window('open');
                        }
                    }]
                });
            },
            loadFilter: function(data) {
            	var datax = {};
            	if (data.total && data.total > 0) {
        			datax.total = data.total;
        			datax.rows = data.tenders;
            	} else {
            		datax.total = 0;
        			datax.rows = new Array();
            	}
            	return datax;
            }
    	});
    
	}

    function changeTenderPattern(inviteFlag) {
	    if (inviteFlag) {
	        $('#tender_list_edit_form #btn_select_vender').linkbutton('enable');
	        $('#tender_list_edit_form #invited_vender').show();
	        tenderPattern = 2;
	    } else {
	        $('#tender_list_edit_form #btn_select_vender').linkbutton('disable');
	        $('#tender_list_edit_form #invited_vender').hide();
	        tenderPattern = 1;
	    }
	}
    
    function showProductWin(index, productData) {
        $('#tender_list_win_product').window({
            onOpen: function() {
                $('#tender_list_product_form #product_name').textbox({
            		height: 28,
            		width: 290,
            		required: true,
            		validType: {
            			length: [1, 100]
            		}
            	});
        	    
        	    $('#tender_list_product_form #quantity').numberbox({
            		height: 28,
            		width: 100,
            		required: true,
            		min: 1,
            		max: 99999
            	});
        	    
        	    $('#tender_list_product_form #unit').textbox({
            		height: 28,
            		width: 100,
            		required: true,
            		validType: {
            			length: [1, 5]
            		}
            	});
        	    
        	    $('#tender_list_product_form #product_description').textbox({
            		height: 80,
            		width: 290,
            		required: true,
            		multiline: true,
            		validType: {
            			length: [1, 100]
            		}
            	});
        	    
        	    $('#tender_list_product_form #btn_save').linkbutton({
        		    onClick: function() {
        		        if ($('#tender_list_product_form').form('validate')) {
        		            var productData = {};
        		            productData.product_name = $('#tender_list_product_form #product_name').textbox('getValue');
        		            productData.quantity = $('#tender_list_product_form #quantity').numberbox('getValue');
        		            productData.unit = $('#tender_list_product_form #unit').textbox('getValue');
        		            productData.product_description = $('#tender_list_product_form #product_description').textbox('getValue');
        		            productData.opt = '';
        		            
        		            var gridData = $('#tender_list_product_grid').datagrid('getData');
        		            var rowIndex = index;
        		            if (index == undefined) {
        			            $('#tender_list_edit_form #tender_list_product_grid').datagrid('appendRow', productData);
        			            rowIndex = $('#tender_list_edit_form #tender_list_product_grid').datagrid('getData').total - 1;
        		            } else {
        		                $('#tender_list_edit_form #tender_list_product_grid').datagrid('updateRow', {
        		                    index: index,
        		                    row: productData
        		                });
        		            }
        		            
        		            $('#tender_list_edit_form .button_edit:eq(' + rowIndex + ')').linkbutton({
                                iconCls: 'icon-edit',
                                onClick: function() {
                                    var index = $(this).index('#tender_list_edit_form .button_edit');
                                    var productData = $('#tender_list_edit_form #tender_list_product_grid').datagrid('getData').rows[index];
                                    showProductWin(index, productData);
                                }
                            });
                            
                            $('#tender_list_edit_form .button_delete:eq(' + rowIndex + ')').linkbutton({
                                iconCls: 'icon-delete',
                                onClick: function() {
                                    var index = $(this).index('#tender_list_edit_form .button_delete');
                                    $('#tender_list_edit_form #tender_list_product_grid').datagrid('deleteRow', index);
                                    $('#tender_list_edit_form #btn_add').linkbutton('enable');
                                }
                            });
        		            
        		            gridData = $('#tender_list_product_grid').datagrid('getData');
        		            if (gridData.total && gridData.total >= 5) {
          	                    $('#tender_list_edit_form #tender_list_btn_add_product').linkbutton('disable');
          	                } else {
          	                    $('#tender_list_edit_form #tender_list_btn_add_product').linkbutton('enable');
          	                }
        		            
        		            $('#tender_list_win_product').window('close');
        		        }
        		    }
        		});
        		
        		$('#tender_list_product_form #btn_cancel').linkbutton({
        		    onClick: function() {
        		        $('#tender_list_win_product').window('close');
        		    }
        		});
        		
                $('#tender_list_product_form').form('clear');
                
                if (productData) {
                    $('#tender_list_win_product #tender_list_product_form #product_name').textbox('setValue', productData.product_name);
		            $('#tender_list_win_product #tender_list_product_form #quantity').numberbox('setValue', productData.quantity);
		            $('#tender_list_win_product #tender_list_product_form #unit').textbox('setValue', productData.unit);
		            $('#tender_list_win_product #tender_list_product_form #product_description').textbox('setValue', productData.product_description);
		            $('#tender_list_win_product #tender_list_product_form #edit_index').val(index);
                }
            },
            onClose: function() {
                $('#tender_list_product_form').form('clear');
            }
        });
        $('#tender_list_win_product').window('open');
    }
    
    function changeStatus(tenderId, status) {
        var paramData = {};
        paramData.tender_id = tenderId;
        paramData.status = status;
        tenderAPI.changeStatus({
  	        onSuccess : function(data) {
  	        	if (data.result) {
  	        	    $('#tender_list_tender_grid').datagrid('reload');
  	        	}
	        },
	        onAPIError : function(status, errors) {
	            $.messager.alert('<s:text name="title.error" />', errors[0].msg);
	        },
	        onServerError : function(jqXHR, textStatus, errorThrown) {
	        }
	    },
	    {
	        param: JSON.stringify(paramData)
	    });
    }
    
    function publishNotice(tenderData, category) {
        var noticeData = {};
        noticeData.tender_id = tenderData.tender_id;
        noticeData.title = tenderData.tender_title;
        noticeData.category = category;
        noticeData.valid_start_date = (new Date()).format('yyyy-MM-dd');
        
        if (category == 2) {
            noticeData.valid_end_date = tenderData.tender_end_date;
        } else if (category == 3) {
            noticeData.valid_end_date = DateAdd('month', 1, tenderData.publish_result_date).format('yyyy-MM-dd');
        } else if (category == 4) {
            noticeData.valid_end_date = tenderData.enroll_end_date;
        }
        
        if (category == 2 || category == 3) {
            findMember(tenderData.tender_id, {
                onSuccess: function(tenderMember) {
                    var enrollMember = tenderMember.enroll_member;
                    var finalistMember = tenderMember.finalist_member;
                    var quoteMember = tenderMember.quote_member;
                    var bidMember = tenderMember.bid_member;
                    if (tenderMember.result) {
                        if (category == 2) {
                            var noticeBody = templates[3].html;
                            noticeBody = noticeBody.replace(new RegExp("{TENDER_TITLE}", "gm"), tenderData.tender_title);
                            noticeBody = noticeBody.replace(new RegExp("{TENDER_NO}", "gm"), tenderData.tender_no);
                            noticeBody = noticeBody.replace(new RegExp("{PUBLISH_DATE}", "gm"), (new Date()).format('yyyy-MM-dd'));
                            noticeBody = noticeBody.replace(new RegExp("{ENROLL_COUNT}", "gm"), enrollMember.length);
                            noticeBody = noticeBody.replace(new RegExp("{FINALIST_COUNT}", "gm"), finalistMember.length);
                            noticeBody = noticeBody.replace(new RegExp("{TENDER_END_DATE}", "gm"), tenderData.tender_end_date);
                            noticeBody = noticeBody.replace(new RegExp("{TENDER_ID}", "gm"), tenderData.tender_id);
                            
                            var member = new Array();
                            $.each(finalistMember, function(index, row) {
                                member.push(row.enterprise_name);
                            });
                            noticeBody = noticeBody.replace(new RegExp("{FINALIST_MEMBER}", "gm"), member.join("、"));
                            noticeData.body = noticeBody;
                        } else if (category == 3) {
                            var noticeBody = templates[4].html;
                            noticeBody = noticeBody.replace(new RegExp("{TENDER_TITLE}", "gm"), tenderData.tender_title);
                            noticeBody = noticeBody.replace(new RegExp("{TENDER_NO}", "gm"), tenderData.tender_no);
                            noticeBody = noticeBody.replace(new RegExp("{PUBLISH_DATE}", "gm"), (new Date()).format('yyyy-MM-dd'));
                            noticeBody = noticeBody.replace(new RegExp("{ENROLL_COUNT}", "gm"), enrollMember.length);
                            noticeBody = noticeBody.replace(new RegExp("{QUOTE_COUNT}", "gm"), quoteMember.length);
                            noticeBody = noticeBody.replace(new RegExp("{BID_MEMBER}", "gm"), bidMember.enterprise_name);
                            noticeData.body = noticeBody;
                        }
                        newsNoticeAPI.publish({
                  	        onSuccess : function(data) {
                  	        	if (data.result) {
                  	        	    $('#tender_list_tender_grid').datagrid('reload');
                  	        	}
                	        },
                	        onAPIError : function(status, errors) {
                	            $.messager.alert('<s:text name="title.error" />', errors[0].msg);
                	        },
                	        onServerError : function(jqXHR, textStatus, errorThrown) {
                	        }
                	    },
                	    {
                	        param: JSON.stringify(noticeData)
                	    });
                    }
                },
                onFailure: function() {
                }
            });
        } else if (category == 4 || category == 5) {
            findProduct(tenderData.tender_id, {
                onSuccess: function(tenderProduct) {
                    if (tenderProduct) {
                        var noticeBody = templates[1].html;
                        noticeBody = noticeBody.replace(new RegExp("{TENDER_TITLE}", "gm"), tenderData.tender_title);
                        noticeBody = noticeBody.replace(new RegExp("{TENDER_NO}", "gm"), tenderData.tender_no);
                        noticeBody = noticeBody.replace(new RegExp("{PUBLISH_DATE}", "gm"), (new Date()).format('yyyy-MM-dd'));
                        noticeBody = noticeBody.replace(new RegExp("{CONTENT_DESCRIPTION}", "gm"), tenderData.content_description);
                        noticeBody = noticeBody.replace(new RegExp("{VENDER_REQUIREMENT}", "gm"), tenderData.vender_requirement);
                        noticeBody = noticeBody.replace(new RegExp("{ENROLL_START_DATE}", "gm"), tenderData.enroll_start_date);
                        noticeBody = noticeBody.replace(new RegExp("{ENROLL_END_DATE}", "gm"), tenderData.enroll_end_date);
                        noticeBody = noticeBody.replace(new RegExp("{CONTACT_NAME}", "gm"), tenderData.contact_name);
                        noticeBody = noticeBody.replace(new RegExp("{CONTACT_TEL}", "gm"), tenderData.contact_tel);
                        $.each(data.products, function(index, row) {
                            noticeBody = noticeBody.replace(new RegExp("{PN" + (index + 1) + "}", "gm"), row.product_name);
                            noticeBody = noticeBody.replace(new RegExp("{Q" + (index + 1) + "}", "gm"), row.quantity);
                            noticeBody = noticeBody.replace(new RegExp("{U" + (index + 1) + "}", "gm"), row.unit);
                            noticeBody = noticeBody.replace(new RegExp("{PD" + (index + 1) + "}", "gm"), row.product_description);
                        });
                        for (data.products.length + 1; i <= 5; i++) {
                            noticeBody = noticeBody.replace(new RegExp("{PN" + i + "}", "gm"), "&nbsp;");
                            noticeBody = noticeBody.replace(new RegExp("{Q" + i + "}", "gm"), "&nbsp;");
                            noticeBody = noticeBody.replace(new RegExp("{U" + i + "}", "gm"), "&nbsp;");
                            noticeBody = noticeBody.replace(new RegExp("{PD" + i + "}", "gm"), "&nbsp;");
                        }
                        noticeData.body = noticeBody;
                        newsNoticeAPI.publish({
                  	        onSuccess : function(data) {
                  	        	if (data.result) {
                  	        	    $('#tender_list_tender_grid').datagrid('reload');
                  	        	}
                	        },
                	        onAPIError : function(status, errors) {
                	            $.messager.alert('<s:text name="title.error" />', errors[0].msg);
                	        },
                	        onServerError : function(jqXHR, textStatus, errorThrown) {
                	        }
                	    },
                	    {
                	        param: JSON.stringify(noticeData)
                	    });
                    }
                },
                onFailure: function() {
                }
            });
            
        }
    }
    
    function findProduct(tenderId, callback) {
        tenderAPI.searchProduct({
  	        onSuccess : function(data) {
  	        	if (data.products && $.isArray(data.products) && data.product.length > 0) {
    	        	callback.onSuccess(data.products);
  	        	} else {
  	        	    callback.onFailure();
  	        	}
	        },
	        onAPIError : function(status, errors) {
	            return null;
	        },
	        onServerError : function(jqXHR, textStatus, errorThrown) {
	            return null;
	        }
	    },
	    {
	        param: JSON.stringify({
	            tender_id: tenderId
	        })
	    });
    }
    
    function findMember(tenderId, callback) {
        tenderAPI.searchMember({
  	        onSuccess : function(data) {
  	        	if (data.result) {
    	        	callback.onSuccess(data);
  	        	} else {
  	        	    callback.onFailure();
  	        	}
	        },
	        onAPIError : function(status, errors) {
	            return null;
	        },
	        onServerError : function(jqXHR, textStatus, errorThrown) {
	            return null;
	        }
	    },
	    {
	        param: JSON.stringify({
	            tender_id: tenderId
	        })
	    });
    }
});
</script>
<div id="tender_list_toolbar" style="padding: 5px;">
  <p>招标名称：<input type="text" id="tender_list_search_title"></p>
</div>
<table id="tender_list_tender_grid"></table>
<div id="tender_list_win_edit" class="easyui-window" title="招标信息" data-options="modal:true, closed:true, collapsible:false, minimizable:false, maximizable:false, resizable:false, iconCls:'icon-edit', shadow:false" style="width:815px; height: auto; padding:10px;">
  <form id="tender_list_edit_form" name="tender_list_edit_form" action="${pageContext.request.contextPath}/file/TenderDocUploadAction.action" method="post" enctype="multipart/form-data" target="upload_frame">
    <table id="tender_list_tender_table" class="edit_table" style="margin-bottom: 10px;">
      <tr>
        <th width="77">招标名称</th>
        <td colspan="7"><input type="text" id="tender_title"></td>
      </tr>
      <tr>
        <th width="77">内容说明</th>
        <td colspan="7"><input type="text" id="content_description"></td>
      </tr>
      <tr>
        <th width="77">供应商要求</th>
        <td colspan="7"><input type="text" id="vendor_requirement"></td>
      </tr>
      <tr>
        <th width="77">报名开始日</th>
        <td width="100"><input type="text" id="enroll_start_date"></td>
        <th width="77">报名截止日</th>
        <td width="100"><input type="text" id="enroll_end_date"></td>
        <th width="77">投标截止日</th>
        <td width="100"><input type="text" id="tender_end_date"></td>
        <th width="77">中标公布日</th>
        <td width="100"><input type="text" id="publish_result_date"></td>
      </tr>
      <tr>
        <th width="77">联系人</th>
        <td width="100"><input type="text" id="contact_name"></td>
        <th width="77">联系电话</th>
        <td width="100"><input type="text" id="contact_tel"></td>
        <th width="77">招标方式</th>
        <td colspan="3" valign="middle">
          <input id="tender_pattern1" name="tender_pattern" type="radio"><label for="tender_pattern1">公开招标</label>&nbsp;&nbsp;
          <input id="tender_pattern2" name="tender_pattern" type="radio"><label for="tender_pattern2">定向邀标</label>
        </td>
      </tr>
      <tr id="invited_vender" style="display: none;">
        <th width="77">供应商</th>
        <td colspan="7"><a id="btn_select_vender" href="#"></a>&nbsp;&nbsp;已选择&nbsp;<label id="vender_count">0</label>&nbsp;供应商</td>
      </tr>
      <tr>
        <th width="77">上传标书</th>
        <td colspan="7">
          <input id="tender_doc" name="tenderDoc" type="text" style="width:500px; height:28px;">
          <iframe width="0" height="0" id="upload_frame" name="upload_frame" style="border: none;"></iframe>
          <input type="hidden" id="upload_param" name="param" />
          <p style="margin-top: 4px;">合法的文件类型为：*.doc;&nbsp;*.docx;&nbsp;*.pdf;&nbsp;*.xls;&nbsp;*.xlsx;</p>
        </td>
      </tr>
    </table>
    <div style="width: 782px; height: 256px;">
      <table id="tender_list_product_grid"></table>
    </div>
    <div id="tender_list_product_toolbar">
      <a id="tender_list_btn_add_product" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'">追加</a>
    </div>
    <div style="text-align: right; margin-top: 5px;">
      <a id="btn_save" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a>
      <a id="btn_cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'">取消</a>
    </div>
  </form>
</div>
<div id="tender_list_win_product" class="easyui-window" title="产品信息" data-options="modal:true, closed:true, collapsible:false, minimizable:false, maximizable:false, resizable:false, iconCls:'icon-product'" style="width:430px; height: auto; padding:10px;">
  <form id="tender_list_product_form">
    <table id="product_table" class="edit_table">
      <tr>
        <th width="75">产品名称</th>
        <td width="300"><input type="text" id="product_name"></td>
      </tr>
      <tr>
        <th>数量/单位</th>
        <td>
          <input type="text" id="quantity">
          <input type="text" id="unit">
        </td>
      </tr>
      <tr>
        <th>产品描述</th>
        <td><input type="text" id="product_description"></td>
      </tr>
    </table>
    <input id="edit_index" type="hidden">
    <div style="text-align: right; margin-top: 5px;">
      <a id="btn_save" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a>
      <a id="btn_cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'">取消</a>
    </div>
  </form>
</div>
<div id="tender_list_win_vender" class="easyui-window" title="选择供应商" data-options="modal:true, closed:true, collapsible:false, minimizable:false, maximizable:false, resizable:false, iconCls:'icon-vender'" style="width:800px; height: 625px;">
  <div style="width: 100%; height: 545px;">
    <table id="vender_grid"></table>
  </div>
  <div style="text-align: right; margin-top: 10px; margin-right: 10px;">
    <a id="btn_select" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">选择</a>
    <a id="btn_cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'">取消</a>
  </div>
</div>
<div id="tender_list_win_condition" class="easyui-window" title="招标信息检索" data-options="modal:true, closed:true, collapsible:false, minimizable:false, maximizable:false, resizable:false, iconCls:'icon-search'" style="width:540px; height: auto; padding:10px;">
  <p style="margin-top: 5px;">
    <span>招标名称：</span>
    <input type="text" id="tender_title" style="width: 320px; height: 28px;">
  </p>
  <p style="margin-top: 5px;">
    <span>报名开始日：&nbsp;&nbsp;&nbsp;&nbsp;从&nbsp;</span>
    <input type="text" id="enroll_start_date_from">&nbsp;开始，到&nbsp;<input type="text" id="enroll_start_date_to">&nbsp;结束
  </p>
  <p style="margin-top: 5px;">
    <span>报名截止日：&nbsp;&nbsp;&nbsp;&nbsp;从&nbsp;</span>
    <input type="text" id="enroll_end_date_from">&nbsp;开始，到&nbsp;<input type="text" id="enroll_end_date_to">&nbsp;结束
  </p>
  <p style="margin-top: 5px;">
    <span>投标截止日：&nbsp;&nbsp;&nbsp;&nbsp;从&nbsp;</span>
    <input type="text" id="tender_end_date_from">&nbsp;开始，到&nbsp;<input type="text" id="tender_end_date_to">&nbsp;结束
  </p>
  <p style="margin-top: 5px;">
    <span>中标公布日：&nbsp;&nbsp;&nbsp;&nbsp;从&nbsp;</span>
    <input type="text" id="publish_result_date_from">&nbsp;开始，到&nbsp;<input type="text" id="publish_result_date_to">&nbsp;结束
  </p>
  <p style="margin-top: 5px;">
    <span>招标方式：</span>
    <input id="tender_pattern" style="width: 100px; height: 28px;" />
    <span>状态：</span>
    <input id="status" style="width: 100px; height: 28px;" />
    <span>发布时间：</span>
    <input id="time_limit" style="width: 100px; height: 28px;" />
  </p>
  <p style="margin-top: 20px; float: right;">
    <a id="btn_search" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width:80px">查询</a>
  </p>
</div>